package com.ruoyi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.order.domain.VerReview;
import com.ruoyi.service.VerReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/review")
public class VerReviewController extends BaseController {
    @Autowired
    private VerReviewService verReviewService;

    /**
     * 查询评论列表
     */
//    @PreAuthorize("@ss.hasPermi('review:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(VerReview verReview) {
        startPage();
        List<VerReview> list = verReviewService.selectVerReviewList(verReview);
        return getDataTable(list);
    }

    /**
     * 获取评论详细信息
     */
//    @PreAuthorize("@ss.hasPermi('review:review:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(verReviewService.selectVerReviewById(id));
    }

    /**
     * 删除评论
     */
//    @PreAuthorize("@ss.hasPermi('review:review:remove')")
    @Log(title = "评论", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(verReviewService.deleteVerReviewByIds(ids));
    }
}
